<?php
/**
 * @author zhaofei
 * @package config function file 
 * @createtime 2014-11-19
 * @updatetime 2014-12-04
 * @ps:系统全局函数工具
 */
defined('SITE_URL') or define('SITE_URL','http://'.$_SERVER['HTTP_HOST']);
defined('CSS_URL') or define('CSS_URL',SITE_URL.'/assets/css/');
defined('JS_URL') or define('JS_URL',SITE_URL.'/assets/js/');
defined('IMG_URL') or define('IMG_URL',SITE_URL.'/assets/img/');
defined('PLUG_URL') or define('PLUG_URL',SITE_URL.'/assets/plugins/');


function js_url($file){
	 $js = "<script type='text/javascript' src='".JS_URL.$file."'></script>";
    return $js;
}
/**
 * @parms 解释 
 * $file:文件  $id $class 宽度，高度
 */
function img_url($file,$id,$class,$w,$h){
	$img = "<img border=0  src='".IMG_URL.$file."'";
	if($w){
		$img.= " width=$w ";
	}
	if($h){
		$img.= " height=$h ";
	}
	if($id){
		$img.= " id=$id ";
	}
	if($class){
		$img.= " class=$class ";
	}
	$img .= "/>";
	return $img;
}

function css_url($file){
	$css = "<link rel='stylesheet' type='text/css' href='".CSS_URL.$file."' media='all'>";
    return $css;
}

function plugins_url($file){
	$string = '';
	//通过后缀判断是js 还是 css
	$files = explode('.', $file);
	$ext = $files[count($files)-1];
	if($ext=='js'){
		 $string = "<script type='text/javascript' src='".PLUG_URL.$file."'></script>";
	}
	if($ext=='css'){
		$string = "<link rel='stylesheet' type='text/css' href='".PLUG_URL.$file."' media='all'>";
	}
	return $string;
}
/* 赵飞 */
function send_email($address,$subject,$body,$IsHTML=false){
	Vendor('Mail.PHPMailer');
	$mail = new \PHPMailer(); //实例化
	$mail->IsSMTP(); // 启用SMTP
	$mail->Host = C('MAIL_Host'); //SMTP服务器 以163邮箱为例子
	$mail->Port = C('MAIL_Port');  //邮件发送端口
	$mail->SMTPAuth   = C('MAIL_SMTPAuth');  //启用SMTP认证

	$mail->CharSet  = C('MAIL_CharSet'); //字符集
	$mail->Encoding = C('MAIL_Encoding'); //编码方式

	$mail->Username = C('MAIL_Username');  //你的邮箱
	$mail->Password = C('MAIL_Password');  //你的密码
	$mail->Subject = $subject; //邮件标题

	$mail->From = C('Mail_From');  //发件人地址（也就是你的邮箱）
	$mail->FromName = "华氏宝贝信使";  //发件人姓名
	$address = $address;//收件人email
	$mail->AddAddress($address, "你好");//添加收件人（地址，昵称）
	$mail->IsHTML($IsHTML); //支持html格式内容
	#$mail->Body = '你好, <b>朋友</b>! <br/>这是一封来自<a href="http://www.helloweba.com" target="_blank">helloweba.com</a>的邮件！<br/><img alt="helloweba" src="cid:my-attach">'; //邮件主体内容
	$mail->Body = $body;
	//发送
	if(!$mail->Send()) {
		return false;
	} else {
		return true;
	}
}



?>